import pyaudio

p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
    devInfo = p.get_device_info_by_index(i)
    # if devInfo['hostApi'] == 0:
    print(devInfo)
# {'index': 4, 'structVersion': 2, 'name': '鑰虫満 (66鐨凙irPods Pro Stereo)', 'hostApi': 0, 'maxInputChannels': 0, 'maxOutputChannels': 2, 'defaultLowInputLatency': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}

